﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Fashion.Models;

namespace Fashion.ViewModels
{
    public class ProductDetailViewModel
    {
        public List<Product> ProductList { get; set; }
        public List<ProductDetail> productDetail { get; set; }
        public int totalProducts { get; set; }

        private FashionEntities1 FashionDB = new FashionEntities1();

        public ProductDetailViewModel()
        {
        }

        public void getListProducts(int start, int offset)
        {
            var productModel = from product in FashionDB.Products
                           orderby product.DateAdded descending
                           select product;
            this.totalProducts = productModel.Count();

            var products = productModel.Skip(start).Take(offset);
            this.ProductList = products.ToList();
        }

        public void getProductDetail(int pid)
        {
            var detail = from product in FashionDB.ProductDetails
                         where product.ProductID == pid
                         select product;
            this.productDetail = detail.ToList();
        }
    }
}